package com.mew.chess.core.game.lh.game.message;

import cn.hutool.core.util.RandomUtil;
import com.mew.chess.core.common.message.response.ChipMessage;
import com.mew.common.config.NicknameUtil;
import com.mew.common.enm.UserType;
import com.mew.common.util.NumberUtil;
import com.mew.common.util.RandomIdUtil;
import com.mew.common.vo.UserSessionVO;
import com.zebra.common.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;


@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class LhUserMessage extends UserSessionVO {

    //主要记录机器人游戏次数
    private int playTimes;
    private int maxPlayTimes;

    private long betNumber;
    private long paymentNumber = -1; //TODO 赔付计算 ，开始清空 -1 表示未参与
    private int tax;

    private List<ChipMessage> bets = new ArrayList<>();

    public void write(ByteBuf b) {
        super.write(b);

        ByteBufUtils.writeLong(b,paymentNumber);
        ByteBufUtils.writeInt(b,bets.size());
        for (ChipMessage bet : bets) {
            bet.write(b);
        }
    }

    @Override
    public String toString() {
        return "LhUserMessage{" +
                "uid=" + getUserId() +
                ", nickname=" + getNickname() +
                ", headPath=" + getHeadPath() +
                ", goldNumber=" + getGoldNumber() +
                ", playTimes=" + playTimes +
                ", maxPlayTimes=" + maxPlayTimes +
                ", betNumber=" + betNumber +
                ", paymentNumber=" + paymentNumber +
                ", bets=" + bets +
                '}';
    }
}
